

/*

 Fourier series  
 Author:Vishwajeet Dusane
*/
#include<stdio.h>
#include<iostream.h>
#include<math.h>





class FourierSeries
{
  public:
  int n; 
  double L,x;
  long double Fx;
  double pi;
  
  void squareWave(float x)
  {
     pi=3.14152942;
     n=1;
     L=0.5;
     Fx=0; 
 
     for(long i=0;i<200;i++)
     {
       Fx=Fx+(4*L/n)*(sin(n*x));   
       n=n+2;
     }	
     cout<< x<<"  "<<Fx<<"\n"; 
  }

};


int main()
{
FourierSeries FS;
  for(float i=0.1;i<10;i=i+0.2)
  {
    FS.squareWave(i);
    //cout<<i<<"  "<<sin(i)<<endl;
  } 
  
  
return 0;
}


